<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        span {
            padding: 2px;
            letter-spacing: 2px;
            font-style: italic;
            background-color: #ddd;
        }
    </style>
</head>

<body>

    <span class="showCode"></span>
    <button>刷新</button>

    <script>







        // 页面一打开的时候  显示验证码
        var oCode = document.querySelector('.showCode');
        // 给标签添加内容
        oCode.innerHTML = randCode(5);


        // 给按钮绑定点击事件
        var oBtn = document.querySelector('button');


        // 绑定点击事件的语法
        oBtn.onclick = function () {
            // 刷新  --- 重新赋值
            oCode.innerHTML = randCode(5);
        }






    </script>

</body>

</html>